import java.util.Arrays;

public class Topic2 {
    /**
     * @Auther: 86176
     * @Date: 2021/4/18 - 04 - 18 - 9:05
     * @Description: PACKAGE_NAME
     * @version: 1.0
     * 
     */

    public static void f1() {
        int[] arr = new int[10];

        for (int i = 0; i < arr.length; i++) {
            arr[i] = i + 1;
        }


        int num = 1;


        for (int k = 0; k < 999; k++) {
            int[] NewArr;

                NewArr = new int[arr.length - arr.length / 3];


            if (num == 1) {
                for (int i = 0; i < NewArr.length; ) {
                    if (num % 3 != 0) {
                        NewArr[i] = arr[num - 1];
                        i++;
                    }
                    num++;

                }
            } else if (num == 2) {
                for (int i = 0; i < NewArr.length; ) {
                    if (num % 3 != 0) {
                        NewArr[i] = arr[num - 2];
                        i++;
                    }
                    num++;
                }
            } else {
                for (int i = 0; i < NewArr.length; ) {
                    if (num % 3 != 0) {
                        NewArr[i] = arr[num - 4];
                        i++;
                    }
                    num++;
                }
            }


            arr = NewArr;
            num = arr.length % 3 + 1;
            System.out.println(Arrays.toString(arr));
            if (NewArr.length == 3) break;
        }

        System.out.println(arr[1]);
    }

    public static void main(String[] args) {
        f1();
    }
}
